
package maquinavirtual;

import controle.Maquina_Virtual;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    
    
    public Main() {
    }

    public static void main(String[] args){
        clear();
        String parametro="";
        if (args.length>1){
            parametro = args[1];
        }
        StringBuffer buffer = new StringBuffer();
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(args[0]));
            while(br.ready()){
                buffer.append(br.readLine()+"\n");
            }
            String[] buff = buffer.toString().split("\n");
            Maquina_Virtual vm = new Maquina_Virtual(buff, parametro);
        } catch (FileNotFoundException ex) {
            System.err.println("Arquivo "+ args[0] + " nao encontrado.");
        }catch (IOException ex) {
            System.err.println("Erro ao acessar o arquivo.");
        }catch (ArrayIndexOutOfBoundsException ex){
            System.err.println("Nehum arquivo foi passado para a maquina virtual.");
        }
        
    }
    
    
    public static void clear(){
        for (int i = 0 ; i< 66; i++){
            System.out.println("\n");
        }
    }
}
